Skip to content

fix(common): run hook Jobs under the app ServiceAccount#23

Open
AMontagu wants to merge 1 commit into
skyloud:nextfrom
AMontagu:fix/common-hook-jobs-serviceaccount
Open

fix(common): run hook Jobs under the app ServiceAccount#23
AMontagu wants to merge 1 commit into
skyloud:nextfrom
AMontagu:fix/common-hook-jobs-serviceaccount

Conversation

@AMontagu

Copy link
Copy Markdown

Problem

templates/deployment.yaml sets serviceAccountName: {{ include "common.fullname" . }}, but templates/jobs.yaml does not — so every hook Job (db-migrate, collectstatic, any .Values.jobs) runs under the namespace default ServiceAccount.

default has no IRSA / EKS Pod Identity, so any AWS call inside a Job fails. Concretely, on a fresh Objow dev env, collectstatic died with:

botocore.exceptions.NoCredentialsError: Unable to locate credentials

pushing static files to S3 — which fails the PreSync phase and blocks the whole rollout. It only bites fresh / cold-start namespaces; existing envs already have their <release>-common SA from a prior sync, so they don't surface it.

Changes

  1. templates/jobs.yaml — set serviceAccountName: {{ include "common.fullname" $ }} on the Job pod spec. ($, not ., because the spec is inside {{- range .Values.jobs }} — same reason the image line uses include "common.image" $.)
  2. templates/serviceaccount.yaml — create the SA as a PreSync hook at sync-wave: "-3" (before hook Jobs, which are typically at -1), so on a fresh namespace the SA exists before the hooks run. Without this, change Add cilium and argocd #1 would fail cold-starts with serviceaccount "<release>-common" not found (the SA was a plain Sync-phase resource, created after PreSync hooks). hook-delete-policy: BeforeHookCreation; IRSA/Pod Identity binds by SA name, so the delete+recreate is safe and the running Deployment keeps its already-projected token.
  3. Chart.yaml1.0.191.0.20.

Impact

Strictly an improvement for every consumer: hook Jobs get the same ServiceAccount (and therefore the same IRSA / Pod Identity) as the Deployment, instead of silently running as default. Existing envs are unaffected (their SA already exists; recreating it via PreSync hook is idempotent).

Test plan

  • helm template renders serviceAccountName: <release>-common on the Job pods and the SA with the PreSync-hook annotations (verified locally).
  • Cold-start namespace: SA created in PreSync; db-migrate / collectstatic run under it and reach AWS; PreSync passes.

The Deployment sets serviceAccountName but the hook Jobs do not, so
db-migrate / collectstatic (and any .Values.jobs) run as the namespace
`default` SA. That SA has no IRSA / EKS Pod Identity, so any AWS call in a
Job fails — e.g. collectstatic pushing static files to S3 dies with
botocore NoCredentialsError, which fails the PreSync phase and blocks the
rollout. Only bites fresh/cold-start namespaces; existing envs already have
their SA from a prior sync.

- templates/jobs.yaml: set serviceAccountName: {{ include "common.fullname" $ }}
  on the Job pod spec ($ because it's inside range .Values.jobs).
- templates/serviceaccount.yaml: create the SA as a PreSync hook (sync-wave -3,
  before hook Jobs at -1) so a fresh namespace has it before the hooks run.
  hook-delete-policy BeforeHookCreation; identity binds by SA name so the
  recreate is safe and the running Deployment keeps its projected token.
- Chart.yaml: 1.0.19 -> 1.0.20

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant